const { uploadFiles, deleteFiles, moveFiles } = require("../utils/handleFile")
const Response = require("../utils/ResponseEntity")
class FileUploadController {
    getFile(req, res) {
        //调用这个函数，上传文件
        const uploadImages = uploadFiles()
        uploadImages(req, res, (error) => {
            if (error) {
                console.log("文件上传失败");
                res.send(Response.error({ msg: "上传失败" }))
            } else {
                console.log("文件上传成功");
                console.log(req.files);
                res.send(Response.success({ msg: "上传成功", data: req.files[0].filename }))
            }
        })
    }
    deleteFile(req, res) {
        const { filename } = req.body
        deleteFiles("./public/temp/" + filename)
        res.send(Response.success({ msg: "删除成功" }))
    }
    moveFile(req, res) {
        const { filename } = req.body
        moveFiles()
    }
}
module.exports = new FileUploadController()